//
//  InviteListNewCell.m
//  CBT
//
//  Created by Mr.Zhang on 2019/3/2.
//  Copyright © 2019 Mr.Zhang. All rights reserved.
//

#import "InviteListNewCell.h"

@interface InviteListNewCell()

@property (weak, nonatomic) IBOutlet UIView *rootView;
@property (weak, nonatomic) IBOutlet UIImageView *selectIconImageView;
@property (weak, nonatomic) IBOutlet UIButton *investmentBtn;
@property (weak, nonatomic) IBOutlet UIImageView *layerImageView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *phoneLeftCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *investmentCenterYCon;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *investBtnCenterYCon;
@end

@implementation InviteListNewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.layerImageView.image = [UIImage resizableImageWithName:@"newhuijiao"];
}

#pragma mark - 投资详情
- (IBAction)investMentBtnAction:(UIButton *)sender {
    
    if (self.InviteListCellBlock != nil) {
        self.InviteListCellBlock(0,[NSObject dx_isNullOrNilWithObject:self.rewardRecordModel] ? self.invitedDetailsModel.investFlag : self.rewardRecordModel.investFlag,[NSObject dx_isNullOrNilWithObject:self.rewardRecordModel] ? self.invitedDetailsModel.userId : self.rewardRecordModel.userId);
    }
}

- (void)inviteFriends {
    if (self.InviteListCellBlock != nil) {
        self.InviteListCellBlock(1,self.rewardRecordModel.investFlag,self.rewardRecordModel.userId);
    }
}

#pragma mark - 邀请详情
- (IBAction)inviteBtnAction:(UIButton *)sender {
    if (self.InviteListCellBlock != nil) {
        self.InviteListCellBlock(1,self.rewardRecordModel.investFlag,self.rewardRecordModel.userId);
    }
}

-(void)setInvitationRevenueModel:(InvitationReItemModel *)invitationRevenueModel {
    
    _invitationRevenueModel = invitationRevenueModel;
    
    self.phoneLabel.text = [NSString numberExcludeNullString:invitationRevenueModel.registerNo];
    self.timeLabel.text  = [NSString getShowDateMonthDayWithTime:[invitationRevenueModel.createDate longLongValue]];
    self.investmentLabel.text = [NSString stringWithFormat:@"+%@ PC",invitationRevenueModel.amount];
    
    self.phoneLabel.textColor = UIColorFromRGB(0xBDBDBD);
    self.timeLabel.textColor  = UIColorFromRGB(0xBDBDBD);
}

-(void)setRewardRecordModel:(RewardRecordItemModel *)rewardRecordModel {
    
    _rewardRecordModel = rewardRecordModel;
    
    self.phoneLabel.text = [NSString numberExcludeNullString:rewardRecordModel.registerNo];
    self.timeLabel.text  = [NSString getShowDateMonthDayWithTime:[rewardRecordModel.createDate longLongValue]];
    
    self.phoneLabel.textColor = [rewardRecordModel.investFlag intValue] == 0 ? UIColorFromRGB(0xBDBDBD) :  UIColorFromRGB(0x7889FF);
    self.timeLabel.textColor  = [rewardRecordModel.investFlag intValue] == 0 ? UIColorFromRGB(0xBDBDBD) :  UIColorFromRGB(0x7889FF);
   
    self.investmentLabel.textColor =
    [rewardRecordModel.investFlag intValue] ==
    0 ? UIColorFromRGB(0xBDBDBD) : UIColorFromRGB(0x7889FF);
    self.selectIconImageView.image = [UIImage imageNamed: [rewardRecordModel.investFlag intValue] == 0 ? @"meitouzi" : @"youtouzi"];
    
    self.investmentLabel.text = kLocalizedString(@"投资详情",nil);
}

-(void)setInvitedDetailsModel:(InvitedDetailsItemModel *)invitedDetailsModel {
    
    _invitedDetailsModel = invitedDetailsModel;
    
    self.phoneLabel.text = [NSString numberExcludeNullString:invitedDetailsModel.registerNo];
    self.timeLabel.text = [NSString getShowDateMonthDayWithTime:[invitedDetailsModel.createDate longLongValue]];
   
    self.phoneLabel.textColor = [invitedDetailsModel.investFlag intValue] == 0 ? UIColorFromRGB(0xBDBDBD) :  UIColorFromRGB(0x7889FF);
    self.timeLabel.textColor  = [invitedDetailsModel.investFlag intValue] == 0 ? UIColorFromRGB(0xBDBDBD) :  UIColorFromRGB(0x7889FF);
    self.investmentLabel.textColor = [invitedDetailsModel.investFlag intValue] == 0 ? UIColorFromRGB(0xBDBDBD) :  UIColorFromRGB(0x7889FF);
    
    self.selectIconImageView.image = [UIImage imageNamed: [invitedDetailsModel.investFlag intValue] == 0 ? @"meitouzi" : @"youtouzi"];
    self.investmentLabel.text = kLocalizedString(@"投资详情",nil);
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    self.phoneLeftCon.constant = self.hiddenSelectIcon ? -12 : 12;
    self.selectIconImageView.hidden = self.hiddenSelectIcon;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
